#include <stdio.h>

int main()
{
    char buffer[50];
    int num = 42;
    const char *str = "Hello";

    //使用sprintf_s 格式化字符串并检查缓冲区大小
    if(sprintf_s(buffer, sizeof(buffer), "Number: %d , String: %s ", num, str) < 0)
    {
        printf("stprintf_s failed!\n");
        return 1; // 返回错误代码
    }
    else {
        printf("Formatted String: %s\n", buffer);
    }

    return 0;
}